package library.web.servlet.ajax;

import library.persistence.service.AccountService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class IsUsernameExist extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/plain");
        PrintWriter out = resp.getWriter();

        AccountService accountService = new AccountService();

        String username = req.getParameter("username");
//        this.checkCode = req.getParameter("checkcode");
        if(accountService.getAccount(username).getUsername()!=null){
            //用户名已存在
            out.print("Exist");
        }else{
            out.print("Not Exist");
        }
    }
}
